﻿
@{
	ViewBag.Title = "投递资讯";
	Layout = "~/Views/Shared/_Layout.cshtml";
}
@section LocationPath{
	<a class="title" href="/">Devtext.com</a> » <a href="/home/news">资讯</a> » 投递资讯
}

<div class="fl user_left">
	@{Html.RenderAction("LeftNavigtion", "UserNavigation");}
</div>
	<div class="fr user_right">
	<h1 class="user_title">投递资讯</h1>
	<div class="user_tab">
		<ul>
			<li><a href="/home/news/index">全站资讯</a></li>
			<li><a href="/home/news/postbyme">我的资讯</a></li>
			<li class="now"><a href="/home/news/postnews">投递资讯</a></li>
		</ul>
	</div>
	<div class="user_con">
		<div class="fl">
		<div class="user_con_left"><div class="mt5"><label>标题：</label>@Html.TextBox("txtTitle", "", new { @class = "text-input wp95", @maxlength = "200" })</div>
			<div class="mt5"><label>访问路径：</label>@Html.TextBox("txtPath", "", new { @class = "text-input wp95", @maxlength = "200" })</div>
			<div class="mt5"><label>分类：</label>@Html.DropDownList("Cates", null, new { @class = "text-input" })</div>
			<div class="mt5"><label>主题：</label><a onclick="javascript:showPop();" style="cursor: pointer; color:Blue;">选择图片</a>&nbsp;&nbsp;<a onclick="javascript:ClearTopic();" style="cursor: pointer; color:Red;">清除</a>
			<div id="result" style="display: none;">
					</div>
					<input type="hidden" id="logo" name="logo" value="0"  /></div>
			<div class="mt5"><label>内容：</label>@Html.TextArea("txtEditorBody", "", new { @class = "text-input wp95", @rows = "15" })</div>
			<div class="mt5"><label>缩略：</label>@Html.TextArea("txtSummary", "", new { @class = "text-input wp95", @rows = "5", @maxlength = "500" })</div>
			<div class="mt5"><label>Meta Keywords：</label>@Html.TextBox("txtKeywords", "", new { @class = "text-input wp80", @maxlength = "100" })</div>
			<div class="mt5"><label>Meta Description：</label>@Html.TextBox("txtDescription", "", new { @class = "text-input wp80", @maxlength="150"})</div>
			<div class="mt5"><label>来源：</label>@Html.TextBox("txtWebFrom", "", new { @class = "text-input", @maxlength = "50" })</div>
			<div class="mt5"><label>网址：</label>@Html.TextBox("txtWebFromAddress", "", new { @class = "text-input wp80", @maxlength = "500" })</div>
			<div class="mtb5"><button id="btnOK" class="butn_save" onclick="Submit();"><span>投递</span></button></div></div>
		</div>
		<div class="fr user_con_right">
		</div>
		</div>
	</div>
<div class="clearfix">
</div>
	<div id="shadowDiv" style="display: none; width: 100%; height: 100%; position: absolute;
		top: 0px; left: 0px; background-color: #FFF; filter: alpha(opacity=50); opacity: 0.4;
		z-index: 65534; border: solid 0px blue">
	</div>
	<div id="popDiv" style="border: 2px solid #97ACD2; display: none; position: absolute;
		top: 0px; left: 0px; width: 690px; height: 300px; overflow-y: auto; z-index: 65535;
		background-color: #fff;">
		<div id="popTitle" style="border-bottom: 0px solid #ccc; height: 25px;">
			<strong style="float: left; margin-left: 15px; font-size: 14px; margin-top: 5px;">选择主题图片</strong><a
				href="###" onclick="hidePop()" id="dialogBoxClose" style="color: #999999; text-decoration: none;
				float: right; margin-right: 15px; font-size: 14px; margin-top: 5px;">X 关闭</a>
			<div class="clear">
			</div>
		</div>
		<div>
			<div id="poppicture">
				<ul id="poppic_list">
				</ul>
			</div>
		</div>
	</div>
<script src="/Editor/kindeditor40/kindeditor-min.js" type="text/javascript"></script>
<script src="/Editor/kindeditor40/lang/zh_CN.js" type="text/javascript"></script>
<script type="text/javascript" src="/Scripts/popup.js" ></script>
<script type="text/javascript">
	var editor;
	KindEditor.ready(function (K) {
		editor = K.create('#txtEditorBody');
	});

	function Submit() {
		if ($.trim($("#txtTitle").val()).length <= 0) {
			alert("请输入资讯标题");
			return;
		}
		editor.sync();
		var content = $("#txtEditorBody").val();
		if ($.trim(content).length <= 0) {
			alert("请输入资讯内容");
			return;
		}
		if ($.trim($("#txtSummary").val()).length <= 0) {
			alert("请输入资讯的缩略");
			return;
		}

		var cates = [];
		var cate = { ID: $("#Cates option:selected").attr("value") };
		cates.push(cate);

		var news = {
			Title: $.trim($("#txtTitle").val()),
			Path: $.trim($("#txtPath").val()),
			Summary: $.trim($("#txtSummary").val()),
			ArticleContent: $.trim(content),
			WebFrom: $.trim($("#txtWebFrom").val()),
			WebFromAddress: $.trim($("#txtWebFromAddress").val()),
			MetaKeywords: $.trim($("#txtKeywords").val()),
			MetaDescription: $.trim($("#txtDescription").val()),
			TopicID: $("#logo").val(),
			NewsCategories: cates
		};
		$.post("/home/news/submitnews", { json: JSON.stringify(news) }, function (data) {
			if (data.success) {
				alert(data.message);
				location.replace("/home/news/postbyme");
			} else {
				alert(data.message);
			}
		}, "json");
	}
</script>